import { Meta, StoryObj } from "@storybook/react";
import { iotDataService } from "_common/service";
import DeviceCard from "components/DeviceCard";
import { Col, Row } from "tdesign-react";
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
iotDataService.setData([
  {
    deviceCode: 1001,
    value1: 12,
    value2: 13,
  },
  {
    deviceCode: 1002,
    value1: 22,
    value2: 22,
  },
]);
// setInterval(() => {
//   iotDataService.setData([
//     {
//       deviceCode: 1001,
//       dtCode: 116,
//       value1: Math.random() * 33,
//       value2: Math.random() * 44,
//       status: Math.floor(Math.random() * 3),
//     },
//     {
//       deviceCode: 1002,
//       dtCode: 116,
//       value1: Math.random() * 33,
//       value2: Math.random() * 44,
//       status: Math.floor(Math.random() * 3),
//     },
//     {
//       deviceCode: 1003,
//       dtCode: 116,
//       value1: Math.random() * 33,
//       value2: Math.random() * 44,
//       status: Math.floor(Math.random() * 3),
//     },
//     {
//       deviceCode: 1004,
//       dtCode: 116,
//       value1: Math.random() * 33,
//       value2: Math.random() * 44,
//       status: Math.floor(Math.random() * 3),
//     },
//     {
//       deviceCode: 1002,
//       value1: Math.random() * 11,
//       value2: Math.random() * 22,
//     },
//     {
//       deviceCode: 1002,
//       value1: Math.random() * 11,
//       value2: Math.random() * 22,
//     },
//     {
//       dtCode: 114,
//       deviceCode: 2024001,
//       value1: Math.floor(Math.random() * 3),
//       value2: (Math.random() * 11) % 2 == 0 ? 1 : 2,
//     },
//     {
//       dtCode: 111,
//       deviceCode: 16001,
//       value1: Math.floor(Math.random() * 2),
//       value2: (Math.random() * 11) % 2 == 0 ? 1 : 2,
//     },
//   ]);
// }, 1000);
const meta: Meta<typeof DeviceCard> = {
  title: "Component/DeviceCard",
  component: DeviceCard,
  tags: ["autodocs"],
  parameters: {
    layout: "padded", // fullscreen//centered//padded
  },
  decorators: [
    (Story) => {
      return (
        <Row gutter={[10, 10]}>
          <Col span={4}>
            <Story />
          </Col>
          <Col span={4}>
            <Story />
          </Col>
          <Col span={4}>
            <Story />
          </Col>
        </Row>
      );
    },
  ],
};

export default meta;
type Story = StoryObj<typeof meta>;

// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
export const YG111: Story = {
  name: "16路烟感设备",
  args: {
    device: {
      deviceCode: 111,
      group: {
        groupCode: 111,
      },
    },
  },
};

export const SJ114: Story = {
  name: "水浸设备",
  args: {
    device: {
      deviceCode: 111,
      group: {
        groupCode: 114,
      },
    },
  },
};

export const WD116: Story = {
  name: "集中式温度",
  args: {
    point: {
      id: 111,
      name: "测试点位1",
      code: "111",
      device: {
        deviceCode: 2024001,
        group: {
          groupCode: 116,
        },
      },
    },
  },
};

export const JZJ109: Story = {
  name: "加脂机",
  args: {
    device: {
      deviceCode: 444,
      group: {
        groupCode: 109,
      },
    },
  },
};

export const WSD112: Story = {
  name: "温湿度设备",
  args: {
    point: {
      id: 111,
      name: "测试点位1",
      code: "111",
      device: {
        deviceCode: 2024001,
        group: {
          groupCode: 112,
        },
      },
    },
  },
};
